﻿using UnityEngine.UI;
using Com.ZX;
using Com.ZX.View;
using Com.ZX.ViewModel;
using FairyGUI;
using Com.ZX.Manager;
using UnityEngine;
using DG.Tweening;

public class TestOne: BaseUIView<TestOneModel>
{
    //GList testList;
    GButton testBtn;
    public TestOne()
    {
        //this.ViewModel.name.OnValueChanged

    }
    protected override void OnInit()
    {
        base.OnInit();

        this.contentPane = UIPackage.CreateObject("TestOne", "Main").asCom;

        this.testBtn = this.contentPane.GetChild("n2").asButton;
        //this.testList = this.contentPane.GetChild("n4").asList;

        this.testBtn.onClick.Add(() => { this.contentPane.GetTransition("t0").Play(); });
        //this.testList.itemRenderer = (index, gobj) => 
        //{

        //};
        this.Center();
        CustomDebug.Log(testBtn.name);
    }

    protected override void OnShown()
    {
        base.OnShown();
        CustomDebug.Log(this.name);
    }

    protected override void DoShowAnimation()
    {
        base.DoShowAnimation();
        this.SetScale(0.1f, 0.1f);
        this.SetPivot(0.5f, 0.5f);
        this.TweenScale(new Vector2(1, 1), 3f).SetEase(Ease.InCubic).OnComplete(this.OnShown);
    }
    //public override void onInit()
    //{
    //    base.onInit();
    //}

    //prote

    // Use this for initialization
    //   protected override void onStart()
    //{
    //	base.onStart();
    //       //btn = transform.Find("Panel/Button").GetComponent<Button>();

    //	btn.onClick.AddListener(() =>
    //	{
    //           //UIManager.inst.OpenUICloseOther(EnumUIType.TestTwo, 0);
    //           UIManager.inst.OpenUIHideCurrent(EnumUIType.TestTwo, 0);
    //	});
    //}

    protected override void onBindPropertyChanged(BaseViewModel _oldVM, BaseViewModel _newVM)
    {
        base.onBindPropertyChanged(_oldVM, _newVM);
        //if (OldViewModel != null)
        //{
        //    ViewModel.name.Value
        //}

        //if (ViewModel != null)
        //{
        //    nameInputField.text = ViewModel.name.Value;
        //}

    }

    //protected override void onRelease()
    //{
    //    base.onRelease();

    //}


    private void Close()
	{
		//Destroy(gameObject);
	}

    public override EnumUIType GetUIType()
    {
        return EnumUIType.TestOne;
    }
}
